package ml.coursedesign.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    private ApiInfo apiInfo(){
        Contact contact = new Contact("小雪","www.xiaoxue.com","3235139683@qq.com");
        return  new ApiInfo(
                "小雪学习swagger",   //标题
                "小雪要努力学习", //描述
                "v.1.0",   //版本
                "http://www.xiaoxuestudy.com",//组织连接
                contact ,    //作者信息
                "Apach 2.0 许可",  //许可
                "http://www.apache.org/licenses/LICENSE-2.0",  //许可连接
                new ArrayList()) ;  //扩展
    }
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()//通过.select()方法配置扫描接口     RequestHandlerSelector配置如何扫描接口
                .apis(RequestHandlerSelectors.basePackage("ml.coursedesign.controller"))
                .build();
    }
}
